#ifndef FIFO_H
#define FIFO_H

typedef unsigned char uchar;
typedef unsigned int uint;


struct _pfifo
{
    uchar *buffer;
    uint size;
    uint in;
    uint out;
};
typedef struct _pfifo Pfifo;

#define min(a,b) ((a) < (b) ? (a):(b))

void pfifo_reset(Pfifo *p);
uint pfifo_len(Pfifo *p);
uint pfifo_get(Pfifo *fifo, uchar *buffer, uint len);
uint pfifo_put(Pfifo *fifo, uchar *buffer, uint len);
/* size must be 2^n */
Pfifo * pfifo_alloc(uint size);
void pfifo_free(Pfifo *p);

#endif /*FIFO_H*/

